package com.ljx.vod.controller;

import com.ljx.glkt.utils.Result;
import com.ljx.vod.service.VodService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;


/**
 * @author 李捷禧
 * Date: 2023/4/8
 * ClassName: VodController
 */
@Api(tags = "腾讯云点播")
@RestController
@RequestMapping("/admin/vod")
@CrossOrigin
public class VodController {

    @Autowired
    private VodService vodService;

    /**
     * 上传视频
     * @param
     * @return
     * @throws IOException
     */
    //上传视频
    @PostMapping("upload")
    public Result uploadVideo(
            @ApiParam(name = "file", value = "文件", required = true)
            @RequestParam("file") MultipartFile file) throws IOException {
        String videoId = vodService.uploadFile(file);
        return Result.ok(videoId);
    }

    /**
     * 删除视频
     * @param videoSourceId
     * @return
     */
    @DeleteMapping("remove/{videoSourceId}")
    public Result removeVideo( @PathVariable String videoSourceId) {
        vodService.removeVideo(videoSourceId);
        return Result.ok(videoSourceId);
    }

}
